package appapi.mapper;

import appapi.entity.bridge.DeviceWorkCycleEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @version: java version 1.8
 * @Author: Ygp Work
 * @description:
 * @date: 2023-09-15 9:32
 */

@Mapper
public interface DeviceWorkCycleMapper extends BaseMapper<DeviceWorkCycleEntity> {

    @Select("SELECT * FROM device_work_cycle d " +
            "JOIN project p ON d.proj_id = p.proj_id " +
            "JOIN organization o ON p.orga_id = o.orga_id " +
            "WHERE o.orga_id = #{orgaId}")
    List<DeviceWorkCycleEntity> listDevice(@Param("orgaId") Integer orgaId);

    @Select("SELECT COUNT(*) FROM device_work_cycle dwc " +
            "JOIN project p ON dwc.proj_id = p.proj_id " +
            "JOIN organization org ON p.orga_id = org.orga_id " +
            "WHERE dwc.device_name = '塔吊' AND org.orga_id = #{orgaId}")
    int getTowerCountByOrgaId(@Param("orgaId") Integer orgaId);

    @Select("SELECT COUNT(*) FROM device_work_cycle dwc " +
            "JOIN project p ON dwc.proj_id = p.proj_id " +
            "JOIN organization org ON p.orga_id = org.orga_id " +
            "WHERE dwc.device_name = '升降机' AND org.orga_id = #{orgaId}")
    int getLiftCountByOrgaId(@Param("orgaId") Integer orgaId);

}